unit fusuariotroca;

{$mode objfpc}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, Buttons, md5;

type

  { TFormUsuarioTrocar }

  TFormUsuarioTrocar = class(TForm)
    ButtonSair: TBitBtn;
    ButtonLogar: TBitBtn;
    EditLogin: TEdit;
    EditSenha: TEdit;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    procedure ButtonSairClick(Sender: TObject);
    procedure ButtonLogarClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  FormUsuarioTrocar: TFormUsuarioTrocar;

implementation

uses
  dmusuario, fprincipal;

{ TFormUsuarioTrocar }

procedure TFormUsuarioTrocar.ButtonLogarClick(Sender: TObject);
var
  usuario: TDadosUsuario;
begin
  usuario.login := EditLogin.Text;
  usuario.senha := MD5Print(MD5String(EditSenha.Text));
  if DataUsuario.VerificaLogin(usuario) then
  begin
    FormUsuarioTrocar.Close();
    FormPrincipal.HabilitaBotoes();
    EditSenha.Clear();
    EditLogin.Clear();
  end
  else
  begin
    ShowMessage('Login e senha não conferem!');
  end;
end;

procedure TFormUsuarioTrocar.ButtonSairClick(Sender: TObject);
begin
  FormUsuarioTrocar.Close();
  Close();
  FormPrincipal.Close();
end;

initialization
  {$I fusuariotroca.lrs}

end.
